<template>
  <div class="update-gender">
    <van-picker
      show-toolbar
      title="选择性别"
      :columns="columns"
      @cancel="$emit('close')"
      @confirm="submit"
      :default-index="value"
    />
  </div>
</template>

<script>
import {updateUserProfile} from '@/api/user'
export default {
  name: 'UpdateGender',
  components: {},
  props: {
    value:{
      type:Number
    }
  },
  data () {
    return {
       columns: ['男', '女']
    }
  },
  methods: {
  async submit(value,index){
    try {
        let {data} =await updateUserProfile({
          gender:index
        })
        this.$emit('input',index)
        this.$emit('close')
      } catch (error) {
        this.$toast.fail('修改失败')
      }
   }
  }
}
</script>

<style scoped lang="less">
</style>